/*
 * Copyright 1999-2011 Alibaba Group.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.alibaba.dubbo.demo.provider;

import com.alibaba.dubbo.common.URL;
import com.alibaba.dubbo.demo.DemoService;
import com.alibaba.dubbo.rpc.RpcContext;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

public class DemoServiceImpl222 implements DemoService {

    /**
     * car是另外一个接口,而且里面有多个实现类,在注入的时候,SPI
     */
    private Car car;

    public void setCar(Car car) {
        this.car = car;
    }

    public String sayHello(String name) {
        System.out.println("这是DemoService的第二个实现类DemoServiceImpl222");
        if(null != car){
            Map<String, String> map = new HashMap ();
            /**
             * 这个参数map的key就是接口名字,value就是下面具体的实现类 benchi=com.alibaba.dubbo.demo.provider.BenchCar
             */
            map.put("car", "benchi");
            URL url = new URL("","",0,map);
            String color = car.color(url);
            System.out.println("car==" + color);
        }
        return "hello " + name + ", this is :DemoServiceImpl222 ";
    }

}